package com.dynamictpm.config;

import com.dynamictpm.client.ClientWorker;
import com.dynamictpm.core.ConfigService;
import com.dynamictpm.core.ThreadPoolConfigAdapter;
import com.dynamictpm.core.ThreadPoolConfigService;
import com.dynamictpm.core.ThreadPoolOperation;
import com.dynamictpm.toolkit.wrap.DynamicThreadPoolWrap;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * -----------------------------
 * PackageName： com.dynamictpm.config
 * ClassName：DynamicThreadPoolAutoConfiguration
 * Description：线程池配置启动类
 *
 * @author：it-yml CreateTime：2023-07-02
 * -----------------------------
 */
@Slf4j
@Configuration
@AllArgsConstructor
@EnableConfigurationProperties(DynamicThreadPoolProperties.class)
public class DynamicThreadPoolAutoConfiguration {

    private final DynamicThreadPoolProperties dynamicThreadPoolProperties;

    @Bean
    public ConfigService configService() {
        return new ThreadPoolConfigService(dynamicThreadPoolProperties);
    }

    @Bean
    public DynamicThreadPoolBannerHandler threadPoolBannerHandler() {
        return new DynamicThreadPoolBannerHandler();
    }

    @Bean
    public ThreadPoolConfigAdapter threadPoolConfigAdapter() {
        return new ThreadPoolConfigAdapter();
    }

    @Bean
    public ThreadPoolOperation threadPoolOperation() {
        return new ThreadPoolOperation(dynamicThreadPoolProperties);
    }
}
